<?php 
if (isset($_GET['update'])) {
    session_start();
    extract($_POST);
    $tid = $_GET['id'];
    $query = "UPDATE lessons SET topic='$topic' WHERE id='$tid' ";
    mysql_query($query) or die("Error executing '$query':" . mysql_error());
    header("Location: ?");
}

include '../database/connect.php';
$tid=$_GET['id'];
$query = "SELECT * FROM lessons WHERE id='$tid'";
//var_dump($query);
$result = mysql_query($query) or die("Error executing '$query':" . mysql_error());
    while ($row = mysql_fetch_assoc($result)) {
        extract($row);
  } 
?>
<form action="?update=1&id=<?php echo $tid; ?> " method="POST">
    <table border='1'>
        <tr>
            <td>Course</td>
            <td><input type="text" name="course" value="<?php  echo $course;  ?>"/></td>
        </tr>
        <tr>
            <td>Topic</td>
            <td><input type="text" name="topic" value="<?php  echo $topic;  ?>"/></td>
        </tr>
        <tr>
            <td colspan="2" style="text-align: right;"><input type="submit" value='Update'/></td>
        </tr>
    </table>
</form>